package com.zqq.user.service.respository

import com.zqq.baselibrary.http.rx.BaseResp
import com.zqq.baselibrary.http.RetrofitFactory
import com.zqq.user.service.api.UserApi
import com.zqq.user.service.bean.*
import rx.Observable
import javax.inject.Inject

/**
 * 用户相关数据层
 * wc
 * @author zqq on 2018/7/26
 */
class UserRepository @Inject constructor() {

    /* 1. 用户注册*/
    fun register(mobile: String, pwd: String, verifyCode: String): Observable<BaseResp<String>> {
        return RetrofitFactory.instance
                .create(UserApi::class.java)
                .register(RegisterReq(mobile, pwd, verifyCode))
    }


    /* 2. 用户登录 */
    fun login(mobile: String, pwd: String, pushId: String): Observable<BaseResp<UserInfo>> {
        return RetrofitFactory.instance
                .create(UserApi::class.java)
                .login(LoginReq(mobile, pwd, pushId))
    }

    /* 3.编辑用户资料 */
    fun editUser(userIcon: String, userName: String, userGender: String, userSign: String): Observable<BaseResp<UserInfo>> {
        return RetrofitFactory.instance
                .create(UserApi::class.java)
                .editUser(EditUserReq(userIcon, userName, userGender, userSign))
    }

    /* 忘记密码 */
    fun forgetPwd(mobile: String, verifyCode: String): Observable<BaseResp<String>> {
        return RetrofitFactory.instance
                .create(UserApi::class.java)
                .forgetPwd(ForgetPwdReq(mobile, verifyCode))
    }


    /* 重置密码 */
    fun resetPwd(mobile: String, pwd: String): Observable<BaseResp<String>> {
        return RetrofitFactory.instance
                .create(UserApi::class.java)
                .resetPwd(ResetPwdReq(mobile, pwd))
    }

}